#!/usr/bin/env python
# encoding: utf-8
# @author: Lin Han
# @contact: voldemort22@126.com
# @file: update_02_config_20210603.py
# @time: 2021/6/3 13:44
# @desc:
from .views.configs import *

from .utils.mongo_tools import retrieve_all_mongo_values, update_mongo_value

config = retrieve_all_mongo_values({"type": CONFIG_DATA_HISTORY_PART_TYPE}, collection_name=CONFIG_COLLECTION)[0]

import pandas as pd

catia = pd.read_excel("data/CATIA软件版本.xlsx", header=None)


config["configData"]["standard"] = ["吉利", "通用", "长城", "一汽大众", "上汽大众", "奔驰", "宝马"]
config["configData"]["version"] = []
for i in catia.iterrows():
    config["configData"]["version"].append(i[1].values[0].strip())
    update_mongo_value(filter_condition={"type": CONFIG_DATA_HISTORY_PART_TYPE}, new_value={"$set": config}, collection_name=CONFIG_COLLECTION)
